﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TimeStamper.SampleWeb._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

       <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="~/ParserService.svc" />
            </Services>
        </asp:ScriptManager>
    
    <div>
        <input type="text" id="script" onkeydown="parseScript()" />
        <div id="parserMessages">
        </div>
    </div>
    
    <script language="javascript" type="text/javascript">
           var currentTimeTyped = 0;
           function parseScript() {
               currentTimeTyped++;
               setTimeout('parseResults(' + currentTimeTyped +')', 1500);
           }
           function parseResults(timeTyped) {
               if (timeTyped == currentTimeTyped) {
                   var parser = new ParserService();
                   parser.ParseScript(document.getElementById('script').value + " END",
                   function(dateRange) {
                       var dateString = "";
                       for (var i in dateRange.Dates) {
                           dateString += dateRange.Dates[i] + " - ";
                       }
                       document.getElementById('parserMessages').innerHTML = dateString;
                   },
                   function(e) {
                       document.getElementById('parserMessages').innerHTML = e.get_message();
                   });
               }
           }
    </script>
    </form>
</body>
</html>
